/*******************************************************************************
 * Copyright (c) 2010 Marcelo Cataldo, Sangeeth Nambiar
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * ProjectViewPart.java
 * 
 * View part to display the project explorer (Tree view to explore the contents
 * of the graph, its nodes...)
 * 
 * Contributors:
 *    Marcelo Cataldo  - initial implementation 
 *    Sangeeth Nambiar - initial implementation
 *******************************************************************************/
package edu.cmu.isr.dinvenio.ui.views;

import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import edu.cmu.isr.dinvenio.Activator;
import edu.cmu.isr.dinvenio.model.DepsGraph;

public class ProjectViewPart extends ViewPart {
	private TreeViewer viewer;
	/**
	 * 
	 */
	public ProjectViewPart() {
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	public void createPartControl(Composite parent) {
		viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
		viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
		viewer.setContentProvider(new ProjectViewContentProvider());
		viewer.setLabelProvider(new ProjectViewLabelProvider());
		DepsGraph gMod = Activator.myController.getGraphModel();
		if(gMod!=null){
			viewer.setInput(gMod);
		}
//		getViewSite().getPage().addSelectionListener(this);
		getSite().setSelectionProvider(viewer);
//		hookContextMenu();

	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
	 */
	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}

	public void refreshView() {
		viewer.refresh();
	}

}
